import { HttpClient } from './Decorator/HttpClient'
import { PathVariable } from './Decorator/PathVariable'
import { RequestBody } from './Decorator/RequestBody'
import { DeleteMapping, GetMapping, PostMapping, PutMapping } from './Decorator/RequestMapping'
import { HttpMethod } from './http/HttpMethod'
import { HttpRequest } from './http/HttpRequest'

/**
 * main
 * @author 冰凝
 * @date 2022-07-01 下午 04:25
 **/
@HttpClient()
class SysApi {

    @GetMapping('/sys/list')
    public async list(): Promise<Array<any>> {
        return []
    }

    @GetMapping('/sys/detail/{id}')
    public async getOne(@PathVariable('id') id: number): Promise<object> {
        return {}
    }

    @PutMapping('/sys')
    public async create(@RequestBody data: object): Promise<boolean> {
        return true
    }

    @PostMapping('/sys')
    public async update(@RequestBody date: object): Promise<boolean> {
        return true
    }

    @DeleteMapping('/sys/{id}')
    public async delete(@PathVariable('id') id: number): Promise<boolean> {
        return true
    }

}

const request = HttpRequest.build<object>()
    .method(HttpMethod.GET)
    .url('/api/sys/about')
    .addQuery('a', 1)
    .addHeader('Context-type', 'application/json')
    .anchor('title1')
    .body({
        id: 1,
    })
    .timeoutSecond(5)
    .readTimeoutSecond(3)
    .build()

console.debug('测试: ', request.toProtocolMessage())
